// eslint-disable-next-line
import { UserLayout, BasicLayout, RouteView, BlankLayout, PageView } from '@/layouts'

export const asyncRouterMap = [

  {
    path: '/',
    name: 'index',
    component: BasicLayout,
    meta: { title: '首页' },
    redirect: '/goods-management',
    children: [
      // goods
      {
        path: '/goods-management',
        redirect: '/goods-management/goods-list',
        component: PageView,
        meta: { title: '商品管理', icon: 'codepen', permission: [ 'form' ] },
        children: [
          {
            path: '/goods-management/new-commodity-category',
            name: 'NewCommodityCategory',
            component: () => import('@/views/goods/NewCommodityCategory'),
            meta: { title: '新增商品分类', keepAlive: true, permission: [ 'form' ] }
          },
          {
            path: '/goods-management/new-goods',
            name: 'NewGoods',
            component: () => import('@/views/goods/NewGoods'),
            meta: { title: '新增商品', keepAlive: true, permission: [ 'form' ] }
          },
          {
            path: '/goods-management/edit-goods',
            name: 'EditGoods',
            hidden: true,
            component: () => import('@/views/goods/EditGoods'),
            meta: { title: '编辑商品', keepAlive: true, permission: [ 'form' ] }
          },
          {
            path: '/goods-management/goods-category-list',
            name: 'GoodsCategoryList',
            component: () => import('@/views/goods/GoodsCategoryList'),
            meta: { title: '商品分类列表', keepAlive: true, permission: [ 'form' ] }
          },
          {
            path: '/goods-management/goods-list',
            name: 'GoodsList',
            component: () => import('@/views/goods/GoodsList'),
            meta: { title: '商品列表', keepAlive: true, permission: [ 'form' ] }
          }
        ]
      },

      // banner
      {
        path: '/banner',
        name: 'banner',
        component: PageView,
        redirect: '/banner/new-banner',
        meta: { title: 'Banner管理', icon: 'file-jpg', permission: [ 'table' ] },
        children: [
          {
            path: '/banner/new-banner',
            name: 'NewBanner',
            hideChildrenInMenu: true, // 强制显示 MenuItem 而不是 SubMenu
            component: () => import('@/views/banner/NewBanner'),
            meta: { title: '新增Banner', keepAlive: true, permission: [ 'table' ] }
          },
          {
            path: '/banner/banner-list',
            name: 'BannerList',
            component: () => import('@/views/banner/BannerList'),
            meta: { title: 'Banner列表', keepAlive: true, permission: [ 'table' ] }
          },
          {
            path: '/banner/banner-edit',
            name: 'EditBanner',
            component: () => import('@/views/banner/EditBanner'),
            hidden: true,
            meta: { title: '编辑Banner', keepAlive: true, permission: [ 'table' ] }
          }
        ]
      },

      // order
      {
        path: '/order',
        name: 'order',
        component: PageView,
        redirect: '/order/order-list',
        meta: { title: '订单管理', icon: 'table', permission: [ 'table' ] },
        children: [
          {
            path: '/order/order-list',
            name: 'OrderList',
            component: () => import('@/views/order/OrderList'),
            meta: { title: '订单列表', keepAlive: true, permission: [ 'table' ] }
          },
          {
            path: '/order/order-pay',
            name: 'OrderPay',
            component: () => import('@/views/order/OrderPay'),
            meta: { title: '支付明细', keepAlive: true, permission: [ 'table' ] }
          },
          {
            path: '/order/order-detail',
            name: 'OrderDetail',
            hidden: true,
            component: () => import('@/views/order/OrderDetail'),
            meta: { title: '订单详情', keepAlive: true, permission: [ 'table' ] }
          }
        ]
      },

      // batch
      {
        path: '/batch',
        name: 'batch',
        component: PageView,
        redirect: '/batch/new-batch',
        meta: { title: '批次管理', icon: 'check-circle-o', permission: [ 'result' ] },
        children: [
          {
            path: '/batch/new-batch',
            name: 'NewBatch',
            component: () => import(/* webpackChunkName: "result" */ '@/views/batch/NewBatch'),
            meta: { title: '新增批次', keepAlive: true, permission: [ 'result' ] }
          },
          {
            path: '/batch/edit-batch',
            name: 'EditBatch',
            hidden: true,
            component: () => import(/* webpackChunkName: "result" */ '@/views/batch/EditBatch'),
            meta: { title: '编辑批次', keepAlive: true, permission: [ 'result' ] }
          },
          {
            path: '/batch/batch-list',
            name: 'BatchList',
            component: () => import(/* webpackChunkName: "result" */ '@/views/batch/BatchList'),
            meta: { title: '批次列表', keepAlive: true, permission: [ 'result' ] }
          }
        ]
      },
      // user
      {
        path: '/userInfo',
        name: 'userInfo',
        component: PageView,
        redirect: '/UserInfo/user-info/user-list',
        meta: { title: '用户管理', icon: 'user', permission: [ 'result' ] },
        children: [
          {
            path: '/user-info/user-list',
            name: 'UserInfoList',
            component: () => import(/* webpackChunkName: "result" */ '@/views/userInfo/UserInfoList'),
            meta: { title: '用户列表', keepAlive: true, permission: [ 'result' ] }
          },
          {
            path: '/user-info/user-address',
            name: 'UserInfoAddress',
            component: () => import(/* webpackChunkName: "result" */ '@/views/userInfo/UserInfoAddress'),
            meta: { title: '用户地址', keepAlive: true, permission: [ 'result' ] }
          },
          {
            path: '/user-info/address-management',
            name: 'AddressManagement',
            component: () => import(/* webpackChunkName: "result" */ '@/views/userInfo/AddressManagement'),
            meta: { title: '地址管理', keepAlive: true, permission: [ 'result' ] }
          }
        ]
      }
    ]
  },
  {
    path: '*', redirect: '/404', hidden: true
  }
]

/**
 * 基础路由
 * @type { *[] }
 */
export const constantRouterMap = [
  {
    path: '/user',
    component: UserLayout,
    redirect: '/user/login',
    hidden: true,
    children: [
      {
        path: 'login',
        name: 'login',
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/Login')
      },
      {
        path: 'register',
        name: 'register',
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/Register')
      },
      {
        path: 'register-result',
        name: 'registerResult',
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/RegisterResult')
      }
    ]
  },

  {
    path: '/test',
    component: BlankLayout,
    redirect: '/test/home',
    children: [
      {
        path: 'home',
        name: 'TestHome',
        component: () => import('@/views/Home')
      }
    ]
  },

  {
    path: '/404',
    component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/404')
  }

]
